package net.csdn.business.discuss.api.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.csdn.business.discuss.api.model.entity.DiscussConfig;
import net.csdn.business.discuss.api.model.entity.DiscussId;
import net.csdn.business.discuss.api.model.query.DiscussConfigQuery;
import net.csdn.business.discuss.api.model.vo.DiscussConfigVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 讨论配置Mapper接口
 * 
 * @author zhangyl
 * @date 2023-07-21
 */
public interface DiscussConfigMapper extends BaseMapper<DiscussConfig>
{

    /**
     * 查询讨论配置
     *
     * @param query 查询参数
     * @return 讨论配置
     */
    @Select("select * from discuss_config where source_id=#{query.sourceId} and source_type=#{query.sourceType}")
    public DiscussConfigVO selectDiscussConfig(@Param("query")DiscussConfigQuery query);

    @Select("select is_open from discuss_config where source_id=#{query.sourceId} and source_type=#{query.sourceType}")
    public Integer isShowDiscuss(@Param("query")DiscussConfigQuery query);


    @Insert("INSERT INTO discuss_config (source_id,source_type,is_open,created_by) VALUES (#{sourceId},#{sourceType},#{isOpen},#{createdBy}) on duplicate key update is_open = #{isOpen},last_modified_by=#{createdBy}")
    int updateDiscussConfig(DiscussConfig discussConfig);
}
